import request from '@/utils/request'

export interface NoticeQuery {
  page: number
  size: number
  title?: string
  status?: string
  type?: string
  isTop?: string
  isUrgent?: string
}

export interface Notice {
  id?: number
  title: string
  content: string
  status: string
  priority: number
  createdBy?: number
  createdAt?: string
  updatedAt?: string
  publishedAt?: string
}

export const noticeApi = {
  // 获取公告列表
  getNotices(params: NoticeQuery) {
    return request.get('/notices', { params })
  },

  // 获取公告详情
  getNotice(id: number) {
    return request.get(`/notices/${id}`)
  },

  // 创建公告
  createNotice(data: Notice) {
    return request.post('/notices', data)
  },

  // 更新公告
  updateNotice(id: number, data: Notice) {
    return request.put(`/notices/${id}`, data)
  },

  // 删除公告
  deleteNotice(id: number) {
    return request.delete(`/notices/${id}`)
  },

  // 发布公告
  publishNotice(id: number) {
    return request.post(`/notices/${id}/publish`)
  },

  // 下线公告
  archiveNotice(id: number) {
    return request.post(`/notices/${id}/archive`)
  }
}